const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');

module.exports = {
	templatePath: 'views',
	dev: {
		assetsPublicPath: '/',
		autoOpenBrowser: true,
		errorOverlay: true,
		devtool: 'cheap-module-eval-source-map',
		contentBase: '../dist',
		proxyTable: {},
		styleLoader: {
			test: /\.scss$/,
			exclude: /node_modules/,
			use: ['style-loader', 'css-loader', 'postcss-loader', 'sass-loader']
		}
	},
	build: {
		assetsRoot: path.resolve(__dirname, '../dist'),
		assetsPublicPath: '',
		productionSourceMap: false,
		devtool: '#source-map',
		styleLoader: {
			test: /\.scss$/,
			exclude: /node_modules/,
			use: ExtractTextPlugin.extract({
				fallback: "style-loader",
				use: [{
					loader: "css-loader",
					options: {
						// 开启 css 压缩
						minimize: true,
					}
				}, {
					loader: "postcss-loader"
				}, {
					loader: "sass-loader"
				}],
				publicPath: '../'
			})
		}
	}
}